﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PowerTest.Admin
{
    public partial class frmMonHoc : Form
    {
        public frmMonHoc()
        {
            InitializeComponent();
        }

        private void frmMonHoc_Load(object sender, EventArgs e)
        {
            try
            {
                // TODO: This line of code loads data into the 'powerTestDataSet.tblMonHoc' table. You can move, or remove it, as needed.
                this.tblMonHocTableAdapter.Fill(this.powerTestDataSet.tblMonHoc);
                // TODO: This line of code loads data into the 'powerTestDataSet.tblMonHoc' table. You can move, or remove it, as needed.
                this.tblMonHocTableAdapter.Fill(this.powerTestDataSet.tblMonHoc);
                // TODO: This line of code loads data into the 'powerTestDataSet.tblMucDo' table. You can move, or remove it, as needed.
                this.tblMucDoTableAdapter.Fill(this.powerTestDataSet.tblMucDo);
            }
            catch{}

        }

        private void btLuu_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Bạn chắc chắn muốn lưu mọi thay đổi?", "Xac Nhan", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    Validate();
                    tblMucDoBindingSource.EndEdit();
                    tblMucDoTableAdapter.Update(powerTestDataSet.tblMucDo);
                    powerTestDataSet.AcceptChanges();
                }
            }
            catch
            {
                MessageBox.Show("Lỗi khi lưu dữ liệu! \n", "Canh Bao");
            }
        }

        private void btXoa_Click(object sender, EventArgs e)
        {
            try
            {
                tblMucDoBindingSource.RemoveCurrent();
            }
            catch
            {
                MessageBox.Show("Lỗi");
            }
        }

        private void btXoaMon_Click(object sender, EventArgs e)
        {
            try
            {
                tblMonHocBindingSource.RemoveCurrent();
            }
            catch
            {
                MessageBox.Show("Lỗi");
            }
        }

        private void btLuuMon_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Bạn chắc chắn muốn lưu mọi thay đổi?", "Xac Nhan", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    Validate();
                    tblMonHocBindingSource.EndEdit();
                    tblMonHocTableAdapter.Update(powerTestDataSet.tblMonHoc);
                    powerTestDataSet.AcceptChanges();
                }
            }
            catch
            {
                MessageBox.Show("Lỗi khi lưu dữ liệu! \n", "Canh Bao");
            }
        }

        private void btThem_Click(object sender, EventArgs e)
        {
            try
            {
                tblMucDoBindingSource.AddNew();
            }
            catch { MessageBox.Show("Lỗi!"); }
        }

        private void btThoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btThemMon_Click(object sender, EventArgs e)
        {

            try
            {
                tblMonHocBindingSource.AddNew();
            }
            catch { MessageBox.Show("Lỗi!"); }
        }
    }
}
